package com.sgb.kjwl.utils;

import android.text.InputFilter;
import android.text.Spanned;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Describe:    输入过滤器
 * 只能输入中英文和数字
 * Author:  yangLei
 * Date:    2021/12/28
 */
public class ChineseEnglishAndNumberFilter implements InputFilter {
    @Override
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
        Pattern p = Pattern.compile("[\u4e00-\u9fa5|a-zA-Z|0-9]+");
        Matcher m = p.matcher(source.toString());
        if (!m.matches()) return "";
        return null;
    }
}
